public class AddExpression extends AbstractExpression{
    // 构造方法：调用父类初始化操作数
    public AddExpression(double num1, double num2) {
        super(num1, num2);
    }

    // 实现加法计算
    @Override
    public void calculate() {
        this.result = num1 + num2;
    }

    // 实现加法算式字符串
    @Override
    public String getExpression() {
        if (!isValid) {
            return "无效加法算式";
        }
        return String.format("%.1f + %.1f = %.1f", num1, num2, result);
    }

}
